package com.zhiwang.xiaoqu.widget.transformer

import android.view.View
import androidx.viewpager.widget.ViewPager


class ViewPagerGalleryTransform : ViewPager.PageTransformer {

    private val MAX_SCALE = 0.9f

    override fun transformPage(page: View, position: Float) {

        if (position < -1 || position > 1) {
            page.scaleX = MAX_SCALE
            page.scaleY = MAX_SCALE
        } else {
            val scaleFactory = Math.max(MAX_SCALE, 1 - Math.abs(position))

            page.scaleX = scaleFactory
            page.scaleY = scaleFactory
        }
    }
}